#include "./include/std.h"
#include "./include/network.h"
//#include "./include/pthread.h"
//#include "./include/foodmenu.h"

int main(void)
{
	struct networkindex *ni_obj = NULL;
	ni_obj = (struct networkindex *)calloc(1, sizeof(struct networkindex));

	pointlist_init(&ni_obj->rl_head);
	pointlist_init(&ni_obj->sl_head);

	sendlist_show_foreach(&ni_obj->sl_head);
	if(0 != udp_server_init(ni_obj))
	{
		return -1;
	}
	while(1)
	{
		//recvlist_show_foreach(&ni_obj->rl_head);
		//printf("\n--------------------------\n");
		//sendlist_show_foreach(&ni_obj->sl_head);
		//printf("\n--------------------------\n");
		sleep(500000);
		//system("reset");
	}











	/*int i, len;
	char *fm_name[] = {"胡萝卜炒蛋", "酸辣鸡杂", "四季豆肉丝", "白菜萝卜", "小鸡炖蘑菇"};
	int fm_price[] = {12, 15, 14, 13, 11};
	int fm_remain[] = {20, 20, 20, 20, 20};
	char *fm_comment[] = {"胡萝卜", "鸡杂", "四季豆", "白菜", "蘑菇"};
	int fm_time[] = {5, 6, 4, 5, 15};

	len = sizeof(fm_name) / sizeof(char *);

	POINTLIST_HEAD_DECLARED(pl_head);
	pointlist_init(pl_head);
	for(i = 0; i < len; i++)
	{
		foodmenu_add(pl_head, fm_name[i], fm_price[i], fm_remain[i], fm_comment[i], fm_time[i]);
	}
	foodmenu_show_foreach(pl_head);*/
	
	/*pthread_t network_listen, network_connect;
	pthread_mutex_t *mutex = NULL;
	
	mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
	
	pthread_mutex_init(mutex, NULL);

	printf("Hello world!!!\n");
	udp_init();
	if(pthread_create(&network_listen, NULL, func1, mutex))
	{
		return -1;
	}

	pthread_create(&network_connect, NULL, func2, mutex))
	{
		return -1;
	}

	while(1)
	{
		pthread_mutex_lock(mutex);
		printf("0");
		fflush(stdout);
		pthread_mutex_unlock(mutex);
	}*/
	return 0;
}
